/**
 * Created by arnold.zhu on 7/3/2017.
 */
import React from 'react';
import {hashHistory} from 'react-router';

const RootComponent = React.createClass({
  componentWillUpdate(nextProps){
    console.info(nextProps.location.pathname);
    if (nextProps.location.pathname != '/') {
      if (localStorage.getItem('userInfo') == null) {
        hashHistory.push('/');
      }
    } else {
      if (localStorage.getItem('userInfo') != null) {
        hashHistory.push('/main/home');
      }
    }
  },
  render: function () {
    return (
      <div>
        {this.props.children}
      </div>
    )
  }
});

export default RootComponent;